package gov.cn.user.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class AjaxResult {
    private Integer code;
    private Boolean success;
    private String msg;
    private Object data;

    public static AjaxResult ok() {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(200);
        ajaxResult.setSuccess(true);
        ajaxResult.setMsg("成功");
        return ajaxResult;
    }

    public static AjaxResult ok(Object data) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(200);
        ajaxResult.setSuccess(true);
        ajaxResult.setMsg("成功");
        ajaxResult.setData(data);
        return ajaxResult;
    }

    public  static  AjaxResult fail() {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(400);
        ajaxResult.setSuccess(false);
        ajaxResult.setMsg("fail");
        return ajaxResult;
    }

    public  static  AjaxResult fail(String msg) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(400);
        ajaxResult.setSuccess(false);
        ajaxResult.setMsg(msg);
        return ajaxResult;
    }

}
